from module.static_module.parent.view import SubWindowView
from module.static_module.main_window.view import MainWindowView

from tools.view import *


class BacktestingView(SubWindowView):
    def __init__(self, main_window_view: MainWindowView):
        super().__init__(main_window_view)
        self.class_name = Module.Backtesting.value
        tk.Label(self.frame, text=self.class_name).pack()

    def create_layout_init(self):
        # 绘制标签、内容组件
        # 配置参数
        # 当前模型名
        now_model_name = self.main_window_view.master.file_manager.now_model_name
        # 行情数据文件
        data_name_ls = self.main_window_view.master.dynamic_module_model_dc[self.main_window_view.master.file_manager.now_dynamic_module].data_name_ls
        # 策略名列表
        strategy_name_ls = self.main_window_view.master.dynamic_module_model_dc[self.main_window_view.master.file_manager.now_dynamic_module].strategy_name_ls
        # 研究方案名
        research_plan_ls = self.main_window_view.master.dynamic_module_model_dc[self.main_window_view.master.file_manager.now_dynamic_module].research_plan_ls
        # 结果文件夹名
        result_folder_ls = self.main_window_view.master.dynamic_module_model_dc[self.main_window_view.master.file_manager.now_dynamic_module].result_folder_ls

        label_config = [
            [LabelMember.ModelName, WidgetCategory.Label, [now_model_name], [0]],
            [LabelMember.DataName, WidgetCategory.Combobox, data_name_ls, [0]],
            [LabelMember.StrategyName, WidgetCategory.Combobox, strategy_name_ls, [0]],
            [LabelMember.ResearchPlan, WidgetCategory.Combobox, research_plan_ls, [0]],
            [LabelMember.ResultFolder, WidgetCategory.Entry, result_folder_ls, [0]]
        ]
        button_config = [
            [ButtonMember.Run, WidgetCategory.Button, None],
            [ButtonMember.OnlyReport, WidgetCategory.Button, None]
        ]
        self.auto_layout = AutoLayout(self.frame, label_config, button_config)
        self.auto_layout.button_command(self)



